#include "myprogramm.h"
#include <QDebug>
#include <QDeclarativeContext>
#include <QTextCodec>
#include <QMessageBox>
#include <QDir>
#include <stdexcept>
#include <algorithm>
#include <stdlib.h>
#ifdef _WIN32
#include "shlobj.h"
#endif
#include "dcpp/Client.h"
#include "dcpp/ClientManager.h"
#include "dcpp/ClientListener.h"
#include "dcpp/ChatMessage.h"
#include "dcpp/DCPlusPlus.h"
#include "dcpp/Download.h"
#include "dcpp/DownloadManager.h"
#include "dcpp/FavoriteManager.h"
#include "dcpp/FavoriteUser.h"
#include "dcpp/FinishedItem.h"
#include "dcpp/FinishedManager.h"
#include "dcpp/HashManager.h"
#include "dcpp/HashValue.h"
#include "dcpp/HubEntry.h"
#include "dcpp/Magnet.h"
#include "dcpp/QueueManager.h"
#include "dcpp/QueueItem.h"
#include "dcpp/SearchManager.h"
#include "dcpp/SettingsManager.h"
#include "dcpp/UploadManager.h"
#include "dcpp/SearchResult.h"
#include "dcpp/ShareManager.h"
#include "dcpp/Upload.h"
#include "dcpp/UserConnection.h"
#include "dcpp/Util.h"
#include "favoritehubsaver.h"
#include "globaldefinition.h"
#include "initvalues.h"
#include "qmlapplicationviewer.h"
#include "viewmodel.h"
#include "actions.h"
#include "dcpp/ConnectionManager.h"

#define TRICE_CLIENTMANAGERLISTENER
#define TRICE_QUEUEMANAGERLISTENER
#define TRICE_SEARCHMANAGERLISTENER
#define TRICE_CONNECTIONMANAGERLISTENER
#define TRICE_DOWNLOADMANAGERLISTENER
#define TRICE_FAVORITEMANAGERLISTENER
#define TRICE_FINIHEDMANAGERLISTENER
#define TRICE_HASHMANAGERLISTENER
#define TRICE_UPLOADMANAGERLISTENER
#define TRICE_USERCONNECTIONLISTENER

#define PRINT_FinishedFileItemPtr QObject::trUtf8("%0").arg(ffi->getFileSize())
#define PRINT_HintedUser QObject::trUtf8("%0 %1").arg(_q(hu.user->getCID().toBase32())).arg(_q(hu.hint))
#define PRINT_FinishedUserItemPtr "FinishedUserItemPtr"
#define PRINT_TTHValue QObject::trUtf8("%0").arg(_q(hash.toBase32()));
//#define PRINT_USERCONNECTION QObject::trUtf8("%0").arg(uc->getHubURL()).arg(uc->)

using namespace dcpp;
using namespace std;

inline void addHubToFavorite(const QString &adress, const QString &nick){
    FavoriteHubEntry entry;
    //        entry.setConnect(1);
    entry.setName(_tq(adress));
    entry.setServer(_tq(adress));
    entry.setEncoding("WINDOWS-1251");
    entry.setNick(nick.toStdString());
    //        entry.setPassword(map["PASS"].toString().toStdString());
    //        entry.setUserDescription(map["UDESC"].toString().toStdString());
    //        entry.setDescription(map["DESC"].toString().toStdString());
    //        entry.setExternalIP(map["IP"].toString().toStdString());
    //        entry.setClientId(map["TAG"].toString().toStdString());
    //        entry.setOverrideId(map["OVERTAG"].toBool());
    //        entry.setUseInternetIP(map["IIP"].toBool());
    //        entry.setDisableChat(map["DCHAT"].toBool());
    //        entry.setMode(map["MODE"].toInt());
    //        entry.setSearchInterval(map["SINT"].toInt());
    FavoriteManager::getInstance()->addFavorite(entry);
}

void initBootScren(QmlApplicationViewer * bootScren){
    bootScren->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    bootScren->setWindowFlags(Qt::FramelessWindowHint);
    bootScren->setMainQmlFile(QLatin1String("qml/PeerON_Qt/scren.qml"));
    bootScren->showExpanded();
}

void initMainWindow(QmlApplicationViewer * mainWindow, ViewModel * vm, MyProgramm * ctrl){
    mainWindow->rootContext()->setContextProperty("veiwModel", vm);
    mainWindow->rootContext()->setContextProperty("controller", ctrl);
    mainWindow->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    mainWindow->setWindowFlags(Qt::FramelessWindowHint);
    mainWindow->setMinimumSize(1024, 538);
    mainWindow->setMainQmlFile(QLatin1String("qml/PeerON_Qt/main.qml"));
}

void initPath(){
    Util::PathsMap pm;
    /** Global configuration */
    pm[Util::PATH_GLOBAL_CONFIG] = getenv("APPDATA") + ("\\" + QCoreApplication::applicationName().toStdString() + "\\");
    /** Per-user configuration (queue, favorites, ...) */
    pm[Util::PATH_USER_CONFIG] = pm[Util::PATH_GLOBAL_CONFIG];
    /** Per-user local data (cache, temp files, ...) */
    pm[Util::PATH_USER_LOCAL] = pm[Util::PATH_USER_CONFIG];
    /** Various resources (help files etc) */
    pm[Util::PATH_RESOURCES] = pm[Util::PATH_GLOBAL_CONFIG];
    /** Translations */
    pm[Util::PATH_LOCALE] = pm[Util::PATH_GLOBAL_CONFIG] + "tr\\";
    /** Default download location */
    TCHAR path[MAX_PATH];
    pm[Util::PATH_DOWNLOADS] = Text::fromT((::SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path), path)) + "\\Downloads\\";
    /** Default file list location */
    pm[Util::PATH_FILE_LISTS] = pm[Util::PATH_GLOBAL_CONFIG] + "FileLists\\";
    /** Default hub list cache */
    pm[Util::PATH_HUB_LISTS] = pm[Util::PATH_GLOBAL_CONFIG] + "HubLists\\";
    /** Where the notepad file is stored */
    pm[Util::PATH_NOTEPAD] = pm[Util::PATH_GLOBAL_CONFIG] + "Notepad.txt";

    Util::initialize(pm);
}

void MyProgramm::SetDefSettings(){
    SettingsManager * sm = SettingsManager::getInstance();

    sm->set(SettingsManager::INCOMING_CONNECTIONS, SettingsManager::INCOMING_FIREWALL_UPNP);
}

MyProgramm::MyProgramm(QApplication *parent):
    QObject(parent),
    m_vm(new ViewModel(this)),
    m_viewer(new QmlApplicationViewer()),
    m_oldPos(0, 0)
{
    // Регистрирую перечисление.
    qmlRegisterType<Pages>("PeerON", 1, 0, "Pages");

    QmlApplicationViewer bootScren;
    initBootScren(&bootScren);

    InitValues::newInstance();

    QTextCodec * codec = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForCStrings(codec);

    connect(Actions::minimize(), SIGNAL(triggered()), m_viewer, SLOT(showMinimized()));
    connect(Actions::settings(), SIGNAL(triggered()), SLOT(openSettingWindow()));

    initPath();

    // Инициализирую dcpp
    // Калбек и указатель на объект не
    // обязательны (см. исходный код startup)
    dcpp::startup(0, 0);


    ConnectionManager::getInstance()->addListener(this);
    DownloadManager::getInstance()->addListener(this);
    FavoriteManager::getInstance()->addListener(this);
    FinishedManager::getInstance()->addListener(this);
    HashManager::getInstance()->addListener(this);
    QueueManager::getInstance()->addListener(this);
    SearchManager::getInstance()->addListener(this);
    UploadManager::getInstance()->addListener(this);

    SetDefSettings();

    connectHub(InitValues::getInstance()->mainHubURL(), trUtf8("%0_%1").arg(getenv("USERNAME")).arg(rand()));

    initMainWindow(m_viewer, m_vm, this);
    m_viewer->showExpanded();

    bootScren.close();

    // Проверяю поиск и магнетссылки. Нижележащий код до конца конструктора удалить.

//    SearchManager::getInstance()->listen();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("YKYRFXUPHD27AF7MWKHB4KMEX4HOHUCJTIR64FI");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("H7UNBFESRGGCGZOKD6OQZPBKMSWIKDTJSAWIHWI");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("K2ZXTW737CONXFOW5BZVSCR47TQDYNHIGSLZXYY");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("HD7E63X6RH5RLJMXTTEAP7TGQC5NFTJCIQQAOUY");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("SO3Y2X5HBSQIC6V6HQS6WHXHKLYXY2SZRADQUQY");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("54NVUNJND4HGXXIOAUOFKEGYXPV3OQZXVUG5FYA");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("H5YPVHUO5VOL7VYLHH2K6K5Y7LEN6SXYMD7M4II");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("RMZGKHMB265SZXEM3K364JL5SKL4G6SXEV5XIDY");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);


//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("TTH:YKYRFXUPHD27AF7MWKHB4KMEX4HOHUCJTIR64FI");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("TTH:H7UNBFESRGGCGZOKD6OQZPBKMSWIKDTJSAWIHWI");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("TTH:K2ZXTW737CONXFOW5BZVSCR47TQDYNHIGSLZXYY");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("TTH:HD7E63X6RH5RLJMXTTEAP7TGQC5NFTJCIQQAOUY");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("TTH:SO3Y2X5HBSQIC6V6HQS6WHXHKLYXY2SZRADQUQY");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("TTH:54NVUNJND4HGXXIOAUOFKEGYXPV3OQZXVUG5FYA");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("TTH:H5YPVHUO5VOL7VYLHH2K6K5Y7LEN6SXYMD7M4II");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());
//    Sleep(10000);
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    runSearch("TTH:RMZGKHMB265SZXEM3K364JL5SKL4G6SXEV5XIDY");
//    qDebug()<<SearchManager::getInstance()->okToSearch()<<SearchManager::getInstance()->timeToSearch();
//    qDebug()<<_q(SearchManager::getInstance()->getPort());

    //        ShareManager::getInstance()->addDirectory("C:\\QtSDK", "QtSDK");
            qDebug()<<trUtf8("Расшарено %0 файлов общим объёмом %1").arg(ShareManager::getInstance()->getSharedFiles()).arg(ShareManager::getInstance()->getShareSize())<<_q(ShareManager::getInstance()->getOwnListFile());
    //        ShareManager::getInstance()->refresh();

    //        string hash;
    //        string name;
    //        string key;
    //        Magnet::parseUri("magnet:?xt=urn:tree:tiger:IHLALKBKYGUL447FIPUDJUXX2B4QLL3BQBL2NEY&xl=150140638&dn=Naruto+Shippuuden_270.mkv", hash, name, key);

    //        ProcessMagnet pcsMgn(this);
    //        try{
    //            pcsMgn.setLink("magnet:?xt=urn:tree:tiger:IHLALKBKYGUL447FIPUDJUXX2B4QLL3BQBL2NEY&xl=150140638&dn=Naruto+Shippuuden_270.mkv");
    //        }catch (const std::exception& e){
    //            //        qDebug()<<trUtf8("Произошла ошибка при старте загрузки:\n %1").arg(e.what());
    //            QMessageBox::critical(m_viewer, trUtf8("Ошибка"), trUtf8("Произошла ошибка при старте загрузки:\n %1").arg(e.what()));
    //        }

}

MyProgramm::~MyProgramm(){
    //    qDebug()<<trUtf8("Завершение программы. Начинаю звершение dcpp.");
    FavoriteHubModifer::deleteInstance();
    // Корректное завершение работы модуля dcpp.
    dcpp::shutdown();
    qDebug()<<trUtf8("Завершение программы. Завершил dcpp.");
    delete m_viewer;
    qDebug()<<trUtf8("Завершение программы. Удалил m_viewer.");

}

void MyProgramm::openSettingWindow(){
    QmlApplicationViewer * settingsWin = new QmlApplicationViewer();
    settingsWin->rootContext()->setContextProperty("veiwModel", m_vm);
    settingsWin->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    settingsWin->setMainQmlFile(QLatin1String("qml/PeerON_Qt/settings.qml"));
    settingsWin->showExpanded();
}

/** Вернёт указатель на dcpp::Client заполненый данными согласно записи в избранных хабах.
 *
 * @return Указатель на dcpp::Client, если искомый хаб содержится в избранных. Иначе 0.*/
inline Client * getHubFromFavorite(const QString &adress){
    auto * entry = FavoriteManager::getInstance()->getFavoriteHubEntry(_tq(adress));
    if(entry != 0){
        auto * mainHab = ClientManager::getInstance()->getClient(entry->getServer());
        mainHab->setCurrentNick(entry->getNick());
        //    mainHab->setPassword(entry->password);
        mainHab->setEncoding(entry->getEncoding());
        return mainHab;
    }
    else
        return 0;
}

bool MyProgramm::connectHub(const QString &adress, const QString &nick){
    auto client = getHubFromFavorite(adress);
    if(!client){
        qDebug()<<trUtf8("Хаба нет в избранных. Добавлю.");
        addHubToFavorite(adress, nick);
        client = getHubFromFavorite(adress);
    }

    if(client){
        qDebug()<<Q_FUNC_INFO<<_q(client->getAddress());
        client->addListener(this);
        m_vm->addedNewHub(client);
        client->connect();
        return true;
    }else
        return false;
}

void MyProgramm::moveWindows( int x, int y ){
    QPoint globalPos = m_viewer->pos() + QPoint(x, y);
    if(m_oldPos.x() == 0 && m_oldPos.y() == 0) m_oldPos = globalPos;
    if(globalPos != m_oldPos){
        m_viewer->move(m_viewer->pos() + globalPos - m_oldPos);
        m_oldPos = globalPos;
    }
}

void MyProgramm::clearPos(){
    m_oldPos.setX(0);
    m_oldPos.setY(0);
}


void MyProgramm::runSearch(QString s) {
    // см. DCPlusPlus-xxx-src/win32/SearchFrame.cpp, стр. 893.
    bool onlyFree = false;
    bool hideShared = true;
    bool merge = true;
    int64_t llsize = 0;
    SearchManager::SizeModes searchMode = SearchManager::SIZE_DONTCARE;
    SearchManager::TypeModes ftype = SearchManager::TYPE_TTH;
    string ftypestr = "";
    string proba = SETTING(LAST_SEARCH_TYPE);

    // change settings if changed
    if(onlyFree != BOOLSETTING(SEARCH_ONLY_FREE_SLOTS))
        SettingsManager::getInstance()->set(SettingsManager::SEARCH_ONLY_FREE_SLOTS, onlyFree);
    if(hideShared != BOOLSETTING(SEARCH_FILTER_SHARED))
        SettingsManager::getInstance()->set(SettingsManager::SEARCH_FILTER_SHARED, hideShared);
    if(merge != BOOLSETTING(SEARCH_MERGE))
        SettingsManager::getInstance()->set(SettingsManager::SEARCH_MERGE, merge);
    if(ftype == SearchManager::TYPE_ANY) {
        if(ftypestr != SETTING(LAST_SEARCH_TYPE))
            SettingsManager::getInstance()->set(SettingsManager::LAST_SEARCH_TYPE, ftypestr);
    }

    if(s.isEmpty())
        return;

    StringList clients = ClientManager::getInstance()->getHubUrls(ClientManager::getInstance()->getMyCID());
//    for(size_t i = 0, n = hubs().size(); i < n; ++i) {
//        clients.push_back(_tq(hubs().at(i)->address()));
//    }
    if(clients.empty())
        return;

//    switch(sizeMode) {
//    case 1: lsize *= 1024.0; break;
//    case 2: lsize *= 1024.0 * 1024.0; break;
//    case 3: lsize *= 1024.0 * 1024.0 * 1024.0; break;
//    }

//    results->clear();
//    searchResults.clear();

    // Add new searches to the last-search dropdown list
//    if(find(lastSearches.begin(), lastSearches.end(), s) == lastSearches.end())
//    {
//        size_t i = max(SETTING(SEARCH_HISTORY)-1, 0);

//        if(searchBox->size() > i)
//            searchBox->erase(i);
//        searchBox->insertValue(0, s);

//        while(lastSearches.size() > i) {
//            lastSearches.erase(lastSearches.begin());
//        }
//        lastSearches.push_back(s);
//    }

    auto currentSearch = s.split(' ');
    s.clear();
    //strip out terms beginning with -
    for(auto si = currentSearch.begin(); si != currentSearch.end();) {
        if(si->isEmpty()) {
            si = currentSearch.erase(si);
            continue;
        }
        if((*si)[0] != _T('-'))
            s += *si + _T(' ');
        ++si;
    }

//    s = s.mid(0, max(s.size(), static_cast<tstring::size_type>(1)) - 1);
    s = s.trimmed();
    auto token = Util::toString(Util::rand());

    if(llsize == 0)
        searchMode = SearchManager::SIZE_DONTCARE;

    // Get ADC searchtype extensions if any is selected
    StringList extList;
    try {
        if(ftype == SearchManager::TYPE_ANY) {
            // Custom searchtype
            extList = SettingsManager::getInstance()->getExtensions(ftypestr);
        } else if(ftype > SearchManager::TYPE_ANY && ftype < SearchManager::TYPE_DIRECTORY) {
            // Predefined searchtype
            extList = SettingsManager::getInstance()->getExtensions(string(1, '0' + ftype));
        }
    } catch(const SearchTypeException& ex) {
        qDebug()<<trUtf8("Ошибка получения списка расширений для поиска.")<<_q(ex.getError());
        ftype = SearchManager::TYPE_ANY;
    }

    qDebug()<<trUtf8("Поиск: %0").arg(s);
//    auto isHash = (ftype == SearchManager::TYPE_TTH);

    if(SearchManager::getInstance()->okToSearch()) {
        qDebug()<<trUtf8("Начинаю поиск");
        string str = _tq(s);
        SearchManager::getInstance()->search(clients, str, llsize,
            ftype, searchMode, token, extList);
//        if(BOOLSETTING(CLEAR_SEARCH)) // Only clear if the search was sent
//            searchBox->setText(Util::emptyStringT);

    } else {
        auto waitFor = SearchManager::getInstance()->timeToSearch();
        qDebug()<<trUtf8("Искать рано, следующий поиск через %0 секунд.").arg(waitFor);
        // Start the countdown timer
//        initSecond();
    }
}



// Слушатель dcpp::ClientManager

#define HUB (*find_if(hubs().begin(), hubs().end(), [&](HubData *item) { return item->client() == client; }))

void MyProgramm::on(ClientListener::Connecting, Client * client) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("Подключаемся к хабу %0 по адресу %1").arg(client->getHubName().c_str()).arg(client->getAddress().c_str());
#endif
}

void MyProgramm::on(ClientListener::Connected, Client * client) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("Подключились к хабу %0 по адресу %1").arg(client->getHubName().c_str()).arg(client->getAddress().c_str());
#endif
}

void MyProgramm::on(ClientListener::UserUpdated, Client * client, const OnlineUser &) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    //    qDebug()<<Q_FUNC_INFO<<trUtf8("Обновлены данные пользователя на хабе %0 по адресу %1").arg(client->getHubName().c_str()).arg(client->getAddress().c_str());
#endif
}

void MyProgramm::on(ClientListener::UsersUpdated, Client * client, const OnlineUserList &) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    //    qDebug()<<Q_FUNC_INFO<<trUtf8("Обновлены данные пользователей на хабе %0 по адресу %1").arg(client->getHubName().c_str()).arg(client->getAddress().c_str());
#endif
}

void MyProgramm::on(ClientListener::UserRemoved, Client * client, const OnlineUser &) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    //    qDebug()<<Q_FUNC_INFO<<trUtf8("Удалён пользователь на хабе %0 по адресу %1").arg(client->getHubName().c_str()).arg(client->getAddress().c_str());
#endif
}

void MyProgramm::on(ClientListener::Redirect, Client * client, const string &newAdr) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("Пернаправление с хаба %0 по адресу %1 на %2").arg(client->getHubName().c_str()).arg(client->getAddress().c_str()).arg(newAdr.c_str());
#endif
}

void MyProgramm::on(ClientListener::Failed, Client * client, const string & err) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("Ошибка приработе с хабом %0 по адресу %1 : %2").arg(client->getHubName().c_str()).arg(client->getAddress().c_str()).arg(err.c_str());
#endif
}

void MyProgramm::on(ClientListener::GetPassword, Client * client) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("Запрос пароля хабом %0 по адресу %1").arg(client->getHubName().c_str()).arg(client->getAddress().c_str());
#endif
}

void MyProgramm::on(ClientListener::HubUpdated, Client * client) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("Изменены данные хаба %0 по адресу %1").arg(client->getHubName().c_str()).arg(client->getAddress().c_str());
#endif
}

void MyProgramm::on(ClientListener::Message, Client * client, const ChatMessage &msg) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
//        qDebug()<<Q_FUNC_INFO<<trUtf8("Получено сообщение с хаба %0 по адресу %1 : %2").arg(client->getHubName().c_str()).arg(client->getAddress().c_str()).arg(msg.message.c_str());
#endif
//    HUB->addStrToChat(_q(msg.message));
}

void MyProgramm::on(ClientListener::StatusMessage, Client * client, const string &msg, int n) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("Получено сообщение статуса с хаба %0 по адресу %1 : %2, %3").arg(client->getHubName().c_str()).arg(client->getAddress().c_str()).arg(msg.c_str()).arg(n);
#endif
}

void MyProgramm::on(ClientListener::HubUserCommand, Client * client, int n1, int n2, const string & str1, const string & str2) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
//        qDebug()<<Q_FUNC_INFO<<trUtf8("Поьзовательская команда. Хаб %0 по адресу %1. %2 %3 %4 %5").arg(client->getHubName().c_str()).arg(client->getAddress().c_str()).arg(n1).arg(n2).arg(str1.c_str()).arg(str2.c_str());
#endif
}

void MyProgramm::on(ClientListener::HubFull, Client * client) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("Хаб %0 по адресу %1 полон.").arg(client->getHubName().c_str()).arg(client->getAddress().c_str());
#endif
}

void MyProgramm::on(ClientListener::NickTaken, Client * client) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("NickTaken. Хаб %0 по адресу %1").arg(client->getHubName().c_str()).arg(client->getAddress().c_str());
#endif
}

void MyProgramm::on(ClientListener::SearchFlood, Client * client, const string & msg) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("SearchFlood. Хаб %0 по адресу %1. %2").arg(client->getHubName().c_str()).arg(client->getAddress().c_str()).arg(msg.c_str());
#endif
}

void MyProgramm::on(ClientListener::NmdcSearch, Client * client, const string & str1, int n1, int64_t n2, int n3, const string & str2) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
//        qDebug()<<Q_FUNC_INFO<<trUtf8("NmdcSearch. Хаб %0 по адресу %1. %2 %3 %4 %5").arg(client->getHubName().c_str()).arg(client->getAddress().c_str()).arg(str1.c_str()).arg(n1).arg(n2).arg(str2.c_str());
#endif
}

void MyProgramm::on(ClientListener::AdcSearch, Client * client, const AdcCommand &, const CID &) noexcept{
#ifdef TRICE_CLIENTMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<trUtf8("AdcSearch. Хаб %0 по адресу %1.").arg(client->getHubName().c_str()).arg(client->getAddress().c_str());
#endif
}




// Слушатель QueueManager

void MyProgramm::on(QueueManagerListener::Added, QueueItem*item) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getTarget());
#endif
}
void MyProgramm::on(QueueManagerListener::Finished, QueueItem*item, const string&str, int64_t) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getTarget())<<_q(str);
#endif
}
void MyProgramm::on(QueueManagerListener::Removed, QueueItem*item) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getTarget());
#endif
}
void MyProgramm::on(QueueManagerListener::Moved, QueueItem*item, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getTarget())<<_q(str);
#endif
}
void MyProgramm::on(QueueManagerListener::SourcesUpdated, QueueItem*item) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getTarget());
#endif
}
void MyProgramm::on(QueueManagerListener::StatusUpdated, QueueItem*item) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getTarget());
#endif
}
void MyProgramm::on(QueueManagerListener::SearchStringUpdated, QueueItem*item) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getTarget());
#endif
}
void MyProgramm::on(QueueManagerListener::PartialList, const HintedUser&, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}

void MyProgramm::on(QueueManagerListener::RecheckStarted, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(QueueManagerListener::RecheckNoFile, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(QueueManagerListener::RecheckFileTooSmall, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(QueueManagerListener::RecheckDownloadsRunning, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(QueueManagerListener::RecheckNoTree, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(QueueManagerListener::RecheckAlreadyFinished, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(QueueManagerListener::RecheckDone, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(QueueManagerListener::FileMoved, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}

void MyProgramm::on(QueueManagerListener::CRCFailed, Download*, const string&str) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(QueueManagerListener::CRCChecked, Download*) noexcept {
#ifdef TRICE_QUEUEMANAGERLISTENER
#endif
}




// Слушатель SearchManager

void MyProgramm::on(SearchManagerListener::SR, const SearchResultPtr&sr) noexcept{
#ifdef TRICE_SEARCHMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(sr->getFile());
#endif
}



// Слушатель ConnectionManager

void MyProgramm::on(ConnectionManagerListener::Added, ConnectionQueueItem*item) noexcept {
#ifdef TRICE_CONNECTIONMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getToken())<<item->getState();
#endif
}

void MyProgramm::on(ConnectionManagerListener::Connected, ConnectionQueueItem*item) noexcept {
#ifdef TRICE_CONNECTIONMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getToken())<<item->getState();
#endif
}

void MyProgramm::on(ConnectionManagerListener::Removed, ConnectionQueueItem*item) noexcept  {
#ifdef TRICE_CONNECTIONMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getToken())<<item->getState();
#endif
}

void MyProgramm::on(ConnectionManagerListener::Failed, ConnectionQueueItem*item, const string&str) noexcept  {
#ifdef TRICE_CONNECTIONMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getToken())<<item->getState()<<_q(str);
#endif
}

void MyProgramm::on(ConnectionManagerListener::StatusChanged, ConnectionQueueItem*item) noexcept  {
#ifdef TRICE_CONNECTIONMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(item->getToken())<<item->getState();
#endif
}







// Млушатель DownloadManager

/**
 * This is the first message sent before a download starts.
 * No other messages will be sent before this.
 */
void MyProgramm::on(DownloadManagerListener::Requesting, Download *dl) noexcept {
#ifdef TRICE_DOWNLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(dl->getTargetFileName());
#endif
}

/**
 * This is the first message sent before a download starts.
 */
void MyProgramm::on(dcpp::DownloadManagerListener::Starting, Download*dl) noexcept {
#ifdef TRICE_DOWNLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(dl->getTargetFileName());
#endif
}

/**
 * Sent once a second if something has actually been downloaded.
 */
void MyProgramm::on(dcpp::DownloadManagerListener::Tick, const DownloadList&dll) noexcept {
#ifdef TRICE_DOWNLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<dll.size();
#endif
}

/**
 * This is the last message sent before a download is deleted.
 * No more messages will be sent after it.
 */
void MyProgramm::on(dcpp::DownloadManagerListener::Complete, Download*dl) noexcept {
#ifdef TRICE_DOWNLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(dl->getTargetFileName());
#endif
}

/**
 * This indicates some sort of failure with a particular download.
 * No more messages will be sent after it.
 *
 * @remarks Should send an error code instead of a string and let the GUI
 * display an error string.
 */
void MyProgramm::on(dcpp::DownloadManagerListener::Failed, Download*dl, const string&str) noexcept {
#ifdef TRICE_DOWNLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(dl->getTargetFileName())<<_q(str);
#endif
}




// Слушатель FavoriteManager

void MyProgramm::on(FavoriteManagerListener::DownloadStarting, const string&str) noexcept {
#ifdef TRICE_FAVORITEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(FavoriteManagerListener::DownloadFailed, const string&str) noexcept {
#ifdef TRICE_FAVORITEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(FavoriteManagerListener::DownloadFinished, const string&str, bool b) noexcept {
#ifdef TRICE_FAVORITEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str)<<b;
#endif
}
void MyProgramm::on(FavoriteManagerListener::FavoriteAdded, const FavoriteHubEntryPtr hub) noexcept {
#ifdef TRICE_FAVORITEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(hub->getName());
#endif
}
void MyProgramm::on(FavoriteManagerListener::FavoriteRemoved, const FavoriteHubEntryPtr hub) noexcept {
#ifdef TRICE_FAVORITEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(hub->getName());
#endif
}
void MyProgramm::on(FavoriteManagerListener::UserAdded, const FavoriteUser&user) noexcept {
#ifdef TRICE_FAVORITEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(user.getNick());
#endif
}
void MyProgramm::on(FavoriteManagerListener::UserUpdated, const FavoriteUser&user) noexcept {
#ifdef TRICE_FAVORITEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(user.getNick());
#endif
}
void MyProgramm::on(FavoriteManagerListener::UserRemoved, const FavoriteUser&user) noexcept {
#ifdef TRICE_FAVORITEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(user.getNick());
#endif
}
void MyProgramm::on(FavoriteManagerListener::StatusChanged, const UserPtr&user) noexcept {
#ifdef TRICE_FAVORITEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(user->getCID().toBase32());
#endif
}
void MyProgramm::on(FavoriteManagerListener::LoadedFromCache, const string&str1, const string&str2) noexcept {
#ifdef TRICE_FAVORITEMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str1)<<_q(str2);
#endif
}




// Слушатель FinishedManager

void MyProgramm::on(FinishedManagerListener::AddedFile, bool b, const string&str, const dcpp::FinishedFileItemPtr&ffi) noexcept {
#ifdef TRICE_FINIHEDMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<b<<_q(str)<<PRINT_FinishedFileItemPtr;
#endif
}
void MyProgramm::on(FinishedManagerListener::AddedUser, bool, const HintedUser&hu, const dcpp::FinishedUserItemPtr&) noexcept {
#ifdef TRICE_FINIHEDMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<PRINT_HintedUser<<PRINT_FinishedUserItemPtr;
#endif
}
void MyProgramm::on(FinishedManagerListener::UpdatedFile, bool b, const string&str, const dcpp::FinishedFileItemPtr&ffi) noexcept {
#ifdef TRICE_FINIHEDMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<b<<_q(str)<<PRINT_FinishedFileItemPtr;
#endif
}
void MyProgramm::on(FinishedManagerListener::UpdatedUser, bool, const HintedUser&hu) noexcept {
#ifdef TRICE_FINIHEDMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<PRINT_HintedUser<<PRINT_FinishedUserItemPtr;
#endif
}
void MyProgramm::on(FinishedManagerListener::RemovedFile, bool b, const string&str) noexcept {
#ifdef TRICE_FINIHEDMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<b<<_q(str);
#endif
}
void MyProgramm::on(FinishedManagerListener::RemovedUser, bool b, const HintedUser&hu) noexcept {
#ifdef TRICE_FINIHEDMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<b<<PRINT_HintedUser;
#endif
}
void MyProgramm::on(FinishedManagerListener::RemovedAll, bool b) noexcept {
#ifdef TRICE_FINIHEDMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<b;
#endif
}




// Слушатель HashManager

void MyProgramm::on(HashManagerListener::TTHDone, const string& fileName, const TTHValue& hash) noexcept{
#ifdef TRICE_HASHMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(fileName)<<PRINT_TTHValue;
#endif
}






// Слушатель UploadManager
void MyProgramm::on(UploadManagerListener::Starting, Upload*) noexcept {
#ifdef TRICE_UPLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UploadManagerListener::Tick, const UploadList&) noexcept {
#ifdef TRICE_UPLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UploadManagerListener::Complete, Upload*) noexcept {
#ifdef TRICE_UPLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UploadManagerListener::Failed, dcpp::Upload*, const string&str) noexcept {
#ifdef TRICE_UPLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(UploadManagerListener::WaitingAddFile, const HintedUser&, const string&str) noexcept {
#ifdef TRICE_UPLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(UploadManagerListener::WaitingRemoveUser, const HintedUser&hu) noexcept {
#ifdef TRICE_UPLOADMANAGERLISTENER
    qDebug()<<Q_FUNC_INFO<<PRINT_HintedUser;
#endif
}






// Слушатель UserConnection
void MyProgramm::on(UserConnectionListener::BytesSent, UserConnection*, size_t, size_t) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UserConnectionListener::Connected, UserConnection*) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UserConnectionListener::Data, UserConnection*, const uint8_t*, size_t) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UserConnectionListener::Failed, UserConnection*, const string&str) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(UserConnectionListener::ProtocolError, UserConnection*, const string&errMsg) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(errMsg);
#endif
}
void MyProgramm::on(UserConnectionListener::CLock, UserConnection*, const string&str1, const string&str2) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str1)<<_q(str2);
#endif
}
void MyProgramm::on(UserConnectionListener::Key, UserConnection*, const string&str) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(UserConnectionListener::Direction, UserConnection*, const string&str1, const string&str2) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str1)<<_q(str2);
#endif
}
void MyProgramm::on(UserConnectionListener::Get, UserConnection*, const string&str, int64_t n) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str)<<n;
#endif
}
void MyProgramm::on(UserConnectionListener::Send, UserConnection*) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UserConnectionListener::GetListLength, UserConnection*) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UserConnectionListener::MaxedOut, UserConnection*) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UserConnectionListener::ModeChange, UserConnection*) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UserConnectionListener::MyNick, UserConnection*, const string&str) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO<<_q(str);
#endif
}
void MyProgramm::on(UserConnectionListener::TransmitDone, UserConnection*) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UserConnectionListener::Supports, UserConnection*, const StringList&) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UserConnectionListener::FileNotAvailable, UserConnection*) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(UserConnectionListener::Updated, UserConnection*) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}

void MyProgramm::on(AdcCommand::SUP, dcpp::UserConnection*, const AdcCommand&) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(AdcCommand::INF, dcpp::UserConnection*, const AdcCommand&) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(AdcCommand::GET, dcpp::UserConnection*, const AdcCommand&) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(AdcCommand::SND, dcpp::UserConnection*, const AdcCommand&) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(AdcCommand::STA, dcpp::UserConnection*, const AdcCommand&) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(AdcCommand::RES, dcpp::UserConnection*, const AdcCommand&) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
void MyProgramm::on(AdcCommand::GFI, dcpp::UserConnection*, const AdcCommand&) noexcept {
#ifdef TRICE_USERCONNECTIONLISTENER
    qDebug()<<Q_FUNC_INFO;
#endif
}
